<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>选择机构</title>
<link href="/widget/bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"  type="text/css"/>
 {cssjs}
<link href="/res/css/inside_page.css" rel="stylesheet"  type="text/css"/>
<style>
    li{float:left;width:70px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin:.2rem 0;}
    .che_input{float:left;}
</style>
</head>

<body>
<div class="container-fluid larry-wrapper">
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12">
            <section class="panel panel-padding">
                <form id="form1" class="layui-form layui-form-pane" method="post" data-dotype="a" action="./?t=select_dept">
				<table class="layui-table">
				  <colgroup>
					<col width="150">
					<col width="150">
					<col width="200">
					<col>
				  </colgroup>
				  <thead>
				    <tr style="background-color:white;">
					  <th><div class="check_box che_all" title="全选">
							<input type="checkbox" id="_checkall" onclick="checkall(this.checked)" style="display:block;"> 
						   <label class="check" for="" onclick="$('#_checkall').click()">  
								<i class="iconfont" id="#icon-duihao2"></i>
							</label><a style="float:left;margin:-17px 0 0 16px">全选</a>
						</div></th>
					</tr>
					<tr>
					  <th>机构</th>
					</tr> 
				  </thead>
				  <tbody>
				  	<!-- START list -->
					<tr>						
					  	<td>
					  	<li style="width: auto;"><div class="check_box che_input">
							<input id="{id}" name="check" _name="{deptname}" type="checkbox" class="everyvb" style="display:block;">  
							<label class="check checkchild" for="{id}">  
								<i class="iconfont"></i>
							</label><a style="float:left;margin:-17px 0 0 16px">{deptname}</a> 
					      	</div>
						  	<input type="hidden" name="dept_id" id="dept_id" value="{id}"/>
					  	</li>				  
					  	</td>  
					</tr>
					<!-- END list -->
				  </tbody>
				</table> 
                <input class="layui-btn layui-btn-danger" style="margin:0 0 0 580px;" onclick="getAllcheck();" value="确认" type="button"/>
                </form>
            </section>
        </div>
    </div>
</div>
   <script type="text/javascript">
   var deptid=queryStr("deptid");
   if(deptid!=""){
   var deptidarr=deptid.split(',');
	for(var i = 0;i<deptidarr.length;i++){
		$("#"+deptidarr[i]).prop("checked",true);
	}
   }
	function checkall(v){
	    $(":checkbox").each(function(){
			this.checked=v;
		})
	};
	$(".dept_check").each(function(){
		$(this).on("click",function(){
			if($(this).prop("checked")){
				$(this).parent().parent().next().find(":checkbox").prop("checked", true);
			}else{
				$(this).parent().parent().next().find(":checkbox").prop("checked", false);
				$("#_checkall").prop("checked", false);
			}
		});
	});
	$(".checkchild").on("click",function(){
		$("#_checkall").prop("checked", false);
	});
	$("._ytt").on("click",function(){
		if($(this).find(".everyvb").prop("checked")){
			$(this).find(".everyvb").prop("checked", false);
		}else{
			$(this).find(".everyvb").prop("checked", true);
		}
	}); 

	function getAllcheck(){
		var allid="";
		var allidtxt="";
		$(".everyvb").each(function(){
			if($(this).prop("checked")){
				allid+=$(this).attr("id")+",";
				allidtxt+=$(this).attr("_name")+",";
			}
		});
		allid=allid.substring(0,allid.length-1);
		allidtxt=allidtxt.substring(0,allidtxt.length-1);
		$('#dept_id').val(allid);
		var frameid="layui-layer-iframe"+queryStr("fid");
		parent.frames[frameid].$("deptname").attr("title",allidtxt);
		parent.frames[frameid].$("#deptname").val(allidtxt);
		parent.frames[frameid].$("#dept_id").val(allid);
		var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
		parent.layer.close(index); //再执行关闭

	}
    </script>
</body>
</html>